﻿<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<body>loading ... </body>
<script type="text/javascript" src="./a9loader.js"></script>
<script type="text/javascript">
var file2area = {
'bash':"*.sh|*.bash",
'java':"*.java",
'c':"*.c",
'cpp':"*.C|*.cpp|*.h",
'sql':"*.sql"
};
var text = "";
A9Loader.asyncLoadClass('com.trydofor.a9js.ui.pgbar');
A9Loader.asyncLoadClass('com.trydofor.a9text.parser.a9text');
A9Loader.asyncLoadClass('com.trydofor.a9text.render.html.a9text');
A9Loader.runAfterClassLoaded(function(){
try{
    document.body.innerHTML="";
    var pgbar = new ProgressBar(window.document);
    pgbar.show();
    var file = A9Loader.getPageInfo();
    if(A9Util.isBlank(file)){
        file = "doc/cn/a9text/a9text-manual_3.2.txt";
    }
    if(file.indexOf(':')<0){
        file = A9Loader.getPagePath()+file;
    }
    
    pgbar.work(10,'loading text');
    text = A9Loader.syncLoadText(file);
    if(text != "")
    {
        var ldot = file.lastIndexOf('.');
        if(ldot>0)
        {
            var crlf = A9Util.getCRLF(text);
            var extn = file.substr(ldot);
            for(var key in file2area)
            {
                if(file2area[key].indexOf(extn) >=0)
                {
                    text = "========= "+key+":"+file+" =========" 
                         + crlf + text + crlf
                         + "====================================";
                    break;
                }
            }
        }
        //
        var a9dom = new A9Dom(null,A9Dom.type.root); //com.trydofor.a9text.A9Dom
        a9dom.setText(text);
        a9dom.putInfo(A9Dom.type.root$path,A9Util.getDir(file));
        var a9tParser = new A9TextParser();
        a9tParser.setProgressBar(pgbar);
        a9tParser.parse(a9dom,function(prdom){
                var a9tRender = new A9TextRender();
                a9tRender.setProgressBar(pgbar);
                a9tRender.render(prdom,function(rrdom){
                pgbar.done();
                var data = rrdom.getData();
                var linkCss = "";
                for(var i =0; i< data['linkcss'].length; i++)
                    linkCss += "<link href='"+data['linkcss'][i]+"' rel='stylesheet' type='text/css' />";
                var linkJs = "";
                for(var i =0; i< data['linkjs'].length; i++)
                    linkJs += "<scr"+"ipt type='text/javascript' src='"+data['linkjs'][i]+"'></scr"+"ipt>";
                var a9htm = linkCss+linkJs+data['htmltext'];
                var ifr=document.createElement('IFRAME');
                ifr.setAttribute('id','a9text_'+a9dom.getId());
                ifr.setAttribute('src','about:blank');
                ifr.setAttribute('frameborder','0',0);
                ifr.setAttribute('frameSpacing','0');
                ifr.setAttribute('style','overflow-x:auto;overflow-y:auto;');
                //ifr.setAttribute('scrolling','no');
                ifr.setAttribute('width','100%');
                document.body.appendChild(ifr);
                var doc = ifr.contentWindow.document;
                doc.open();
                doc.write("<body>"+a9htm+"</body><scr"+"ipt>window.setTimeout(function(){parent.document.getElementById(\"a9text_"+
                    a9dom.getId()+"\").style.height=document.body.scrollHeight+40},100);</scr"+"ipt>");
                doc.close();
            });
        });
    }
}catch(e){
    document.write("<PRE>"+text+"</PRE>");
}
});
</script>